import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isLogin: false,
    admin: {
      userId: '',
      name: '',
      email: '',
      admin: '',
    }
  },
  mutations: {
    login(state, payload) {
      // state.admin = payload
      state.admin.userId = payload.userId
      state.admin.name = payload.name
      state.admin.email = payload.email
      state.admin.admin = payload.admin

      state.isLogin = true
    },
    logout(state) {
      Object.keys(state.admin).forEach((key) => {
        state.admin[key] = ''
      })
      state.userId = ''
      state.isLogin = false
    },
  },
  actions: {
  },
  modules: {
  }
})
